#include "DebugDrawer.h"
#include <Windows.h>
#include <gl\GL.h>
#include <gl\GLU.h>
#include <iostream>

DebugDrawer::DebugDrawer()
{
	m_debugMode = 0;
}

DebugDrawer::~DebugDrawer()
{
}

void DebugDrawer::drawLine (const btVector3 &from, const btVector3 &to, const btVector3 &color)
{
	Color* newColor = new Color;
	newColor->r = color.x(); newColor->g = color.y(); newColor->b = color.z();
	colors.push_back(newColor);

	Line* line = new Line;
	line->ax = from.x(); line->ay = from.y(); line->az = from.z();
	line->bx = to.x(); line->by = to.y(); line->bz = to.z();
	lines.push_back(line);
}

void DebugDrawer::drawAll()
{
	glBegin(GL_LINES);
	for (unsigned int i = 0; i < lines.size(); ++i) {
		Color* color = colors.at(i);
		Line* line = lines.at(i);
		glColor3f(color->r, color->g, color->b);
		glVertex3f(line->ax, line->ay, line->az);
		glVertex3f(line->bx, line->by, line->bz);
	}
	glEnd();
}

void DebugDrawer::clear()
{
	for (unsigned int i = 0; i < lines.size(); ++i) {
		delete colors.at(i);
		delete lines.at(i);
	}
	lines.clear();
	colors.clear();
}

void DebugDrawer::drawContactPoint (const btVector3 &PointOnB, const btVector3 &normalOnB, btScalar distance, int lifeTime, const btVector3 &color){}
void DebugDrawer::reportErrorWarning (const char *warningString){}
void DebugDrawer::draw3dText (const btVector3 &location, const char *textString)
{

}
void DebugDrawer::setDebugMode (int debugMode)
{
	m_debugMode = debugMode;
}
int	DebugDrawer::getDebugMode () const
{
	return m_debugMode;
}